package com.dragon.repository.domain.dto;

import com.dragon.repository.entity.Announcement;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dragon.common.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AnnouncementDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "公告标题")
    private String title;

    @ApiModelProperty(value = "公告内容")
    private String text;

    @ApiModelProperty(value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "是否启用 0启用 1禁用")
    private Integer status;


    public AnnouncementDTO() {}

    public AnnouncementDTO(Announcement entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static AnnouncementDTO convert(Announcement entity) {
        return new AnnouncementDTO(entity);
    }

    public static List<AnnouncementDTO> convertList(List<Announcement> list) {
        List<AnnouncementDTO> resultList = new ArrayList<>();
        for (Announcement entity : list) {
            resultList.add(new AnnouncementDTO(entity));
        }
        return resultList;
    }}
